package one.four.forteen;

public class FourSum {

	public static int fourSum(int[] a) {
		int r = 0;
		int s = a.length;
		int sum;
		for (int i = 0; i < s; i++) {
			for (int j = i + 1; j < s; j++) {
				for (int m = j + 1; m < s; m++) {
					for (int n = m + 1; n < s; n++) {
						sum = a[i] + a[j] + a[m] + a[n];
						
						if (sum == 0) {
							r++;
							
						}
					}
				}
			}
		}
		return r;
	}

	public static void main(String[] args) {
		int[] a = { 1, 2,3,4,5, -1, -2,5,6,7,0 };
		int r = fourSum(a);

		System.out.println(r);
	}

}
